<custom-tab-bar direction=".0" :show-icon="" :selected="" @onTabItemTap="" /><template>
	<view>
		<view class="megBox" v-for="(item,index) in userInfoList" v-if="userInfoList" @click='goDetail(item.user_id)'>
			<view class="msgLeft">
				<!-- 头像 -->
				<view class="head">
					<image :src="item.imgList[0]" mode="aspectFill"></image>
				</view>
			</view>
			<view class="msgRight">
				<view class="title">
					<view class="name">
						{{item.nickName}}--{{item.age}}
					</view>
					<view class="time">
						{{item.sex}}
					</view>
				</view>
				<view class="content">
					{{item.education}}&nbsp;&nbsp;|&nbsp;&nbsp;{{item.address}}
				</view>
			</view>
		</view>
		<view v-if="noLikeStatus" class='view-center'>
			您暂时还未有喜欢的人，快去和大家互动吧
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfoList: [],
				requestStatus:false,
				noLikeStatus:true,
			}
		},
		onLoad(option) {
			let likemeList = option
			this.likemeList = likemeList
			this.getLikemeList(likemeList)
		},
		methods: {
			getLikemeList(list) {
				uni.showLoading({
					title: '正在加载中'
				})
				let that = this
				if(JSON.stringify(list) !=='{}'){
					let listStr = list.list
					let List = listStr.split(',')
					if (List) {
						List.forEach((item) => {
							let h = {user_id:item}
							console.log(h,'hhh')
							that.$api.users_get(h).then((res) => {
									let userInfoIntro = res.data.data[0]
									if (userInfoIntro) {
										userInfoIntro.age = that.jsGetAge(userInfoIntro.birth)
										that.userInfoList.push(userInfoIntro)
									}
								})
								.catch((res) => {
									console.log(res, 'pppppppp')
								})
						})
						this.noLikeStatus = false
						this.requestStatus = true
					}
				}
				uni.hideLoading()
			},
			jsGetAge(strBirthday) {
				var returnAge;
				var strBirthdayArr = strBirthday.split("-");
				var birthYear = strBirthdayArr[0];
				var birthMonth = strBirthdayArr[1];
				var birthDay = strBirthdayArr[2];
				let d = new Date();
				var nowYear = d.getFullYear();
				var nowMonth = d.getMonth() + 1;
				var nowDay = d.getDate();
				if (nowYear == birthYear) {
					returnAge = 0; //同年 则为0岁  
				} else {
					var ageDiff = nowYear - birthYear; //年之差  
					if (ageDiff > 0) {
						if (nowMonth == birthMonth) {
							var dayDiff = nowDay - birthDay; //日之差  
							if (dayDiff < 0) {
								returnAge = ageDiff - 1;
							} else {
								returnAge = ageDiff;
							}
						} else {
							var monthDiff = nowMonth - birthMonth; //月之差  
							if (monthDiff < 0) {
								returnAge = ageDiff - 1;
							} else {
								returnAge = ageDiff;
							}
						}
					} else {
						returnAge = -1; //返回-1 表示出生日期输入错误 晚于今天  
					}
				}
				return returnAge; //返回周岁年龄    
			},
			goDetail(e){
				let user_id = e
				uni.navigateTo({
					url: "../detail/detail?id=" + user_id
				})
			}
		}
	}
</script>

<style>
	.view-center{
		height: 50vh;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 35rpx;
		color: #f60300;
	}
	.megBox {
		height: 202rpx;
		overflow: hidden;
	}

	.megBox .msgLeft {
		height: 202rpx;
		float: left;
		overflow: hidden;
		position: relative;
	}

	.megBox .msgLeft image {
		width: 108rpx;
		height: 108rpx;
		margin: 26rpx;
		border-radius: 15rpx;
	}

	.megBox .msgLeft .dot {
		width: 36rpx;
		height: 36rpx;
		background-color: #f60300;
		border-radius: 50%;
		color: #fff;
		text-align: center;
		font-size: 20rpx;
		line-height: 36rpx;
		position: absolute;
		top: 16rpx;
		right: 10rpx;
	}

	.megBox .msgRight {
		padding-left: 160rpx;
		border-bottom: 3rpx solid #ededed;
	}

	.megBox .msgRight .title {
		overflow: hidden;
	}

	.megBox .msgRight .name {
		font-size: 32rpx;
		line-height: 96rpx;
		font-weight: bold;
		float: left;
	}

	.megBox .msgRight .time {
		font-size: 24rpx;
		line-height: 42rpx;
		padding: 0 25rpx;
		margin-top: 20rpx;
		margin-left: 16rpx;
		border-radius: 21rpx;
		background-color: #fa575a;
		color: #fff;
		float: left;
	}

	.megBox .msgRight .content {
		font-size: 26rpx;
		line-height: 28rpx;
		margin-bottom: 78rpx;
		color: #6d6d6d;
	}
</style>
